package com.todo.user.application.backend.controller;

import com.todo.common.common.entity.response.BizPageResponse;
import com.todo.common.common.entity.response.BizResponse;
import com.todo.common.common.entity.response.page.PageResult;
import com.todo.user.application.backend.service.UserAccountBackendService;
import com.todo.user.iface.backend.UserAccountBackendIface;
import com.todo.user.iface.backend.request.*;
import com.todo.user.iface.backend.response.QueryUserAccountByConditionResp;
import com.todo.user.iface.backend.response.UserAccountDetailResp;
import com.todo.user.iface.backend.response.UserAuthRecordResp;
import com.todo.user.iface.backend.response.UserOperateRecordResp;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author azhebuxing
 * @date 2024/4/10 10:41
 * @description
 */
@RestController
@RequestMapping("/bd/user")
@Tag(name = "用户账户后台处理类", description = "用户账户后台处理类")
public class UserAccountBackendController implements UserAccountBackendIface {

    @Resource
    private UserAccountBackendService userAccountBackendService;


    @Override
    @Operation(summary = "查询用户详情")
    @PostMapping("/queryUserAccountDetail")
    public BizResponse<UserAccountDetailResp> queryUserAccountDetail(@RequestBody QueryUserAccountDetailReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        UserAccountDetailResp resp = userAccountBackendService.queryUserAccountDetail(req);
        return BizResponse.success(resp);
    }

    @Override
    @Operation(summary = "用户禁言")
    @PostMapping("/mutedUserAccount")
    public BizResponse<Boolean> mutedUserAccount(@RequestBody MutedUserAccountReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        Boolean result = userAccountBackendService.mutedUserAccount(req);
        return BizResponse.success(result);
    }

    @Override
    @Operation(summary = "多条件查询用户账户信息")
    @PostMapping("/queryUserAccountByCondition")
    public BizPageResponse<QueryUserAccountByConditionResp> queryUserAccountByCondition(@RequestBody QueryUserAccountByConditionReq req) {
        if (req == null) {
            return BizPageResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizPageResponse.paramError("参数错误");
        }
        PageResult<QueryUserAccountByConditionResp> pageResult = userAccountBackendService.queryUserAccountByCondition(req);
        return BizPageResponse.success(pageResult);
    }

    @Override
    @Operation(summary = "多条件查询用户操作记录")
    @PostMapping("/queryUserOperateRecordByCondition")
    public BizPageResponse<UserOperateRecordResp> queryUserOperateRecordByCondition(@RequestBody QueryUserOperateRecordByConditionReq req) {
        if (req == null) {
            return BizPageResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizPageResponse.paramError("参数错误");
        }
        PageResult<UserOperateRecordResp> pageResult = userAccountBackendService.queryUserOperateRecordByCondition(req);
        return BizPageResponse.success(pageResult);
    }

    @Override
    @Operation(summary = "查询用户授权记录")
    @PostMapping("/queryUserAuthRecordList")
    public BizResponse<List<UserAuthRecordResp>> queryUserAuthRecordList(@RequestBody QueryUserAuthRecordListReq req) {
        List<UserAuthRecordResp> respList = userAccountBackendService.queryUserAuthRecordList(req);
        return BizResponse.success(respList);
    }
}
